package net.oschina.bilbodai.common.beanutil.bean.code;

import net.oschina.bilbodai.common.beanutil.bean.core.PropertyDumpInfo;
import org.objectweb.asm.MethodVisitor;

/**
 * @author daimao  Date: 16/5/28 Time: 下午4:34
 * @version $Id$
 */
public class SimpleToSimpleApplier extends DumpOverrideAwareApplier {

    public SimpleToSimpleApplier(PropertyDumpInfo dumpInfo) {
        super(dumpInfo);
    }

    @Override
    protected void loadSrcCastPropertyOntoStack(MethodVisitor mv) {
        loadSrcCastPropertyOntoStack0(mv);
    }

    @Override
    protected void doApply(MethodVisitor mv) {
        loadTargetCastOntoStack0(mv);

        if (dumpInfo.usingAttrPathQuery()) {
            dumpInfo.getAttrPathQueryInfo().preCheck(dumpInfo.getSrcField().getType());
            dumpInfo.getAttrPathQueryInfo().applyPath(mv);
        }

        loadSrcCastPropertyOntoStack(mv);

        if (dumpInfo.usingAttrPathQuery()) {
            dumpInfo.getAttrPathQueryInfo().applyInvoke(mv);
        }

        invokeTargetPropertySetter0(mv);
    }

}